﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{


    class id3
    {
        double _entropySystem;
        int _gain;
        int _tmpGain;
        int _saveAttribut;
        int _nbAttributs;
        List<dataset> _myDataList;
        double _mathlog2 = Math.Log(2);
        private Node _MainNode = new Node();
        public bool debug = false;
        

        public id3(List<dataset> myDataList)
        {
            this._myDataList = myDataList;
            this._tmpGain = this._gain = this._saveAttribut = 0;
            this._saveAttribut = -1;
            this._MainNode.datas = this._myDataList;
            //this._MainNode.attTab = {true, true, true, true, true};
        }

        private result findAnswer(Node curNode, dataset data)
        {
            Node temp = null;

            for (int i = 0; i < curNode.nodeTab.Count; ++i)
            {
                if (curNode.nodeTab[i].att == attributs.life)
                {
                    if (curNode.nodeTab[i].val == (int)data.Life)
                        temp = curNode.nodeTab[i];
                }
                else if (curNode.nodeTab[i].att == attributs.Allies)
                {
                    if (curNode.nodeTab[i].val == (int)data.Allies)
                        temp = curNode.nodeTab[i];
                }
                else if (curNode.nodeTab[i].att == attributs.enemylevel)
                {
                    if (curNode.nodeTab[i].val == (int)data.Enemylevel)
                        temp = curNode.nodeTab[i];
                }
                else if (curNode.nodeTab[i].att == attributs.field)
                {
                    if (curNode.nodeTab[i].val == (int)data.Field)
                        temp = curNode.nodeTab[i];
                }
                else if (curNode.nodeTab[i].att == attributs.hunger)
                    if (curNode.nodeTab[i].val == (int)data.Hunger)
                        temp = curNode.nodeTab[i];
            }
            if (temp != null)
            {
                if (temp.nodeTab.Count != 0)
                    return findAnswer(temp, data);
                else
                {
                    if (this.debug)
                    {
                        data.Display();
                        Console.Write("Proba = " + temp.prob.ToString() + "; Res = " + temp.Res.ToString() + "; ");
                    }
                    return temp.Res;
                }
            }
            else
            {
                if (this.debug)
                {
                    data.Display();
                    Console.Write("Proba = " + curNode.prob.ToString() + "; Res = " + curNode.Res.ToString() + "; ");
                }
                return curNode.Res;
            }
        }

        public result doId3(dataset data)
        {
            this.initId3();

            result r = this.findAnswer(this._MainNode, data);
            this._MainNode = new Node();
            return r;
        }

        void initId3()
        {
            this.SystemEntropy();
            this.GenerateNodes(this._myDataList, this._MainNode);
        }    

        void SystemEntropy()
        {
            int nbGood = 0;
            int nbBad = 0;
            
            for (int j = 0; j < this._myDataList.Count; ++j)
            {
                if (this._myDataList[j].Result == 0)
                    ++nbGood;
                else
                    ++nbBad;
            }
            this._entropySystem = -entLine(nbGood, this._myDataList.Count) - entLine(nbBad, this._myDataList.Count);
        }

        void findBestGain(List<dataset> _dataList, Node curNode)
        {
            double tmpGain = 0;
            double Gain = 0;
            this._saveAttribut = -1;

            if (curNode.attTab[(int)attributs.life])
            {
                tmpGain = this.getLifeGain(_dataList);
                if (tmpGain > Gain)
                {
                    Gain = tmpGain;
                    this._saveAttribut = (int)attributs.life;
                }
            }
            
            if (curNode.attTab[(int)attributs.Allies])
            {
                tmpGain = this.getAlliesGain(_dataList);
                if (tmpGain > Gain)
                {
                    Gain = tmpGain;
                    this._saveAttribut = (int)attributs.Allies;
                }
            }

            if (curNode.attTab[(int)attributs.field])
            {
                tmpGain = this.getFieldGain(_dataList);
                if (tmpGain > Gain)
                {
                    Gain = tmpGain;
                    this._saveAttribut = (int)attributs.field;
                }
            }

            if (curNode.attTab[(int)attributs.enemylevel])
            {
                tmpGain = this.getEnemylvlGain(_dataList);
                if (tmpGain > Gain)
                {
                    Gain = tmpGain;
                    this._saveAttribut = (int)attributs.enemylevel;
                }
            }

            if (curNode.attTab[(int)attributs.hunger])
            {
                tmpGain = this.getHungerGain(_dataList);
                if (tmpGain > Gain)
                {
                    Gain = tmpGain;
                    this._saveAttribut = (int)attributs.hunger;
                }
            }
        }
 
        double getEnemylvlGain(List<dataset> dataList)
        {
            double gain = 0;

            double enLow = 0;
            double enMed = 0;
            double enHigh = 0;
            double enVHigh = 0;

            double enLowGood = 0;
            double enMedGood = 0;
            double enHighGood = 0;
            double enVHighGood = 0;

            double entropyEnLow = 0;
            double entropyEnMed = 0;
            double entropyEnHigh = 0;
            double entropyEnVHigh = 0;

            for (int j = 0; j < dataList.Count; ++j)
            {
                if (dataList[j].Enemylevel == enemylevel.low)
                {
                    ++enLow;
                    if (dataList[j].Result == result.good)
                        ++enLowGood;
                }
                else if (dataList[j].Enemylevel == enemylevel.medium)
                {
                    ++enMed;
                    if (dataList[j].Result == result.good)
                        ++enMedGood;
                }
                else if (dataList[j].Enemylevel == enemylevel.high)
                {
                    ++enHigh;
                    if (dataList[j].Result == result.good)
                        ++enHighGood;
                }

                else if (dataList[j].Enemylevel == enemylevel.veryhigh)
                {
                    ++enVHigh;
                    if (dataList[j].Result == result.good)
                        ++enVHighGood;
                }
            }
            if (enLow > 0)
                entropyEnLow = - entLine(enLowGood, enLow) - entLine((enLow - enLowGood), enLow);
            if (enMed > 0)
                entropyEnMed = - entLine(enMedGood, enMed) - entLine((enMed - enMedGood), enMed);
            if (enHigh > 0)
                entropyEnHigh = - entLine(enHighGood, enHigh) - entLine((enHigh - enHighGood), enHigh);
            if (enVHigh > 0)
                entropyEnVHigh = - entLine(enVHighGood, enVHigh) - entLine((enVHigh - enVHighGood), enVHigh);

            if (dataList.Count > 0)
                gain = this._entropySystem - ((enLow / dataList.Count) * entropyEnLow) - ((enMed / dataList.Count) * entropyEnMed) - ((enHigh / dataList.Count) * entropyEnHigh) - ((enVHigh / dataList.Count) * entropyEnVHigh);
            //Console.WriteLine("ent sys " + this._entropySystem.ToString());
            //Console.WriteLine("gain enemy lv " + gain.ToString());
            
            return gain;

        }

        double getAlliesGain(List<dataset> dataList)
        {
            double gain = 0;
            int nb0 = 0;
            int nb1 = 0;
            int nb2 = 0;
            int nb3 = 0;
            int nb0G = 0;
            int nb1G = 0;
            int nb2G = 0;
            int nb3G = 0;

            //double entropy = 0;
            double entropy0 = 0;
            double entropy1 = 0;
            double entropy2 = 0;
            double entropy3 = 0;

            for (int j = 0; j < dataList.Count; ++j)
            {
                if (dataList[j].Allies == allies.zero)
                {
                    ++nb0;
                    if (dataList[j].Result == result.good)
                        ++nb0G;
                }
                else if (dataList[j].Allies == allies.one)
                {
                    ++nb1;
                    if (dataList[j].Result == result.good)
                        ++nb1G;
                }
                else if (dataList[j].Allies == allies.two)
                {
                    ++nb2;
                    if (dataList[j].Result == result.good)
                        ++nb2G;
                }
                else
                {
                    ++nb3;
                    if (dataList[j].Result == result.good)
                        ++nb3G;
                }
            }

            //entropy = -entLine(nb0, dataList.Count) - entLine(nb1, dataList.Count) - entLine(nb2, dataList.Count) - entLine(nb3, dataList.Count);

            entropy0 = -entLine(nb0G, nb0) - entLine((nb0 - nb0G), nb0);
            entropy1 = -entLine(nb1G, nb1) - entLine((nb1 - nb1G), nb1);
            entropy2 = -entLine(nb2G, nb2) - entLine((nb2 - nb2G), nb2);
            entropy3 = -entLine(nb3G, nb3) - entLine((nb3 - nb3G), nb3);
            if (dataList.Count > 0)
                gain = this._entropySystem - ((nb0 / dataList.Count) * entropy0) - ((nb1 / dataList.Count) * entropy1) - ((nb2 / dataList.Count) * entropy2) - ((nb3 / dataList.Count) * entropy3);
            //Console.WriteLine("gain allies " + gain.ToString());
            return gain;
        }

        double getLifeGain( List<dataset> dataList)
        {

            int nbLow = 0;
            int lowGood = 0;
            int nbMedium = 0;
            int mediumGood = 0;
            int nbHigh = 0;
            int highGood = 0;

            double gain = 0;
            //double entropyLife = 0;
            double entropyLow = 0;
            double entropyMedium = 0;
            double entropyHigh = 0;
            

            for (int j = 0; j < dataList.Count ; ++j)
            {
                if (dataList[j].Life == life.low)
                {
                    ++nbLow;
                    if (dataList[j].Result == result.good)
                        ++lowGood;
                }
                else if (dataList[j].Life == life.medium)
                {
                    ++nbMedium;
                    if (dataList[j].Result == result.good)
                        ++mediumGood;
                }
                else
                {
                    ++nbHigh;
                    if (dataList[j].Result == result.good)
                        ++highGood;
                }
            }

            //entropyLife = - entLine(nbLow, dataList.Count) - entLine(nbMedium, dataList.Count) - entLine(nbHigh, dataList.Count);

            entropyLow = - entLine(lowGood, nbLow) - entLine((nbLow-lowGood), nbLow);
            entropyMedium = - entLine(mediumGood, nbMedium) - entLine((nbMedium-mediumGood), nbMedium);
            entropyHigh = - entLine(highGood, nbHigh) - entLine((nbHigh-highGood), nbHigh);
            if (dataList.Count > 0)
                gain = this._entropySystem - ((nbLow / dataList.Count) * entropyLow) - ((nbMedium / dataList.Count) * entropyMedium) - ((nbHigh / dataList.Count) * entropyHigh);
            
            //Console.WriteLine("Gain life " + gain.ToString());

            return gain;
        }

        double getFieldGain(List<dataset> dataList)
        {

            int nbNotFav = 0;
            int nbNotFavG = 0;
            int nbNeutral = 0;
            int nbNeutralG = 0;
            int nbFav = 0;
            int nbFavG = 0;

            double gain = 0;
            //double entropyField = 0;
            double entropyNotFav = 0;
            double entropyNeutral = 0;
            double entropyFav = 0;


            for (int j = 0; j < dataList.Count; ++j)
            {
                if (dataList[j].Field == field.notfav)
                {
                    ++nbNotFav;
                    if (dataList[j].Result == result.good)
                        ++nbNotFavG;
                }
                else if (dataList[j].Field == field.neutral)
                {
                    ++nbNeutral;
                    if (dataList[j].Result == result.good)
                        ++nbNeutralG;
                }
                else
                {
                    ++nbFav;
                    if (dataList[j].Result == result.good)
                        ++nbFavG;
                }
            }

            //entropyField = -entLine(nbNotFav, dataList.Count) - entLine(nbNeutral, dataList.Count) - entLine(nbFav, dataList.Count);

            entropyNotFav = -entLine(nbNotFavG, nbNotFav) - entLine((nbNotFav - nbNotFavG), nbNotFav);
            entropyNeutral = -entLine(nbNeutralG, nbNeutral) - entLine((nbNeutral - nbNeutralG), nbNeutral);
            entropyFav = -entLine(nbFavG, nbFav) - entLine((nbFav - nbFavG), nbFav);

            if (dataList.Count > 0)
                gain = this._entropySystem - ((nbNotFav / dataList.Count) * entropyNotFav) - ((nbNeutral / dataList.Count) * entropyNeutral) - ((nbFav / dataList.Count) * entropyFav);

            //Console.WriteLine("gain field " + gain.ToString());

            return gain;
        }

        double getHungerGain(List<dataset> dataList)
        {

            int nbLow = 0;
            int lowGood = 0;
            int nbMedium = 0;
            int mediumGood = 0;
            int nbHigh = 0;
            int highGood = 0;

            double gain = 0;
            //double entropyHunger = 0;
            double entropyLow = 0;
            double entropyMedium = 0;
            double entropyHigh = 0;


            for (int j = 0; j < dataList.Count; ++j)
            {
                if (dataList[j].Hunger == hunger.low)
                {
                    ++nbLow;
                    if (dataList[j].Result == result.good)
                        ++lowGood;
                }
                else if (dataList[j].Hunger == hunger.medium)
                {
                    ++nbMedium;
                    if (dataList[j].Result == result.good)
                        ++mediumGood;
                }
                else
                {
                    ++nbHigh;
                    if (dataList[j].Result == result.good)
                        ++highGood;
                }
            }

            //entropyHunger = -entLine(nbLow, dataList.Count) - entLine(nbMedium, dataList.Count) - entLine(nbHigh, dataList.Count);

            entropyLow = -entLine(lowGood, nbLow) - entLine((nbLow - lowGood), nbLow);
            entropyMedium = -entLine(mediumGood, nbMedium) - entLine((nbMedium - mediumGood), nbMedium);
            entropyHigh = -entLine(highGood, nbHigh) - entLine((nbHigh - highGood), nbHigh);
            if (dataList.Count > 0)
                gain = this._entropySystem - ((nbLow / dataList.Count) * entropyLow) - ((nbMedium / dataList.Count) * entropyMedium) - ((nbHigh / dataList.Count) * entropyHigh);

            //Console.WriteLine("gain hunger " + gain.ToString());

            return gain;
        }

        double entLine(double nb, double total)
        {
            if (nb == 0 || total == 0)
                return 0;
            double res = (((nb / total) * ((Math.Log(nb / total)) / (_mathlog2))));
            return res;
        }

        public List<dataset> getListWithAttribValue(List<dataset> origine, attributs attrib, int value)
        {
            List<dataset> dest = new List<dataset>();

            if (attrib == attributs.Allies)
            {
                for (int i = 0; i < origine.Count; ++i)
                {
                    if ((int)origine[i].Allies == value)
                        dest.Add(origine[i]);
                }
            }
            else if (attrib == attributs.enemylevel)
            {
                for (int i = 0; i < origine.Count; ++i)
                {
                    if ((int)origine[i].Enemylevel == value)
                        dest.Add(origine[i]);
                }
            }
            else if (attrib == attributs.field)
            {
                for (int i = 0; i < origine.Count; ++i)
                {
                    if ((int)origine[i].Field == value)
                        dest.Add(origine[i]);
                }
            }
            else if (attrib == attributs.hunger)
            {
                for (int i = 0; i < origine.Count; ++i)
                {
                    if ((int)origine[i].Hunger == value)
                        dest.Add(origine[i]);
                }
            }
            else if (attrib == attributs.life)
            {
                for (int i = 0; i < origine.Count; ++i)
                {
                    if ((int)origine[i].Life == value)
                        dest.Add(origine[i]);
                }
            }

            return dest;
        }

        //Attention block de code degeuCrade en apporche

        private void doItForAllies(List<dataset> l, Node curNode)
        {
            Node allies0 = new Node(curNode.attTab);
            allies0.attTab[this._saveAttribut] = false;
            allies0.datas = this.getListWithAttribValue(l, attributs.Allies, (int)allies.zero);
            allies0.val = (int)allies.zero;
            allies0.att = attributs.Allies;
            Node allies1 = new Node(curNode.attTab);
            allies1.attTab[this._saveAttribut] = false;
            allies1.datas = this.getListWithAttribValue(l, attributs.Allies, (int)allies.one);
            allies1.val = (int)allies.one;
            allies1.att = attributs.Allies;
            Node allies2 = new Node(curNode.attTab);
            allies2.attTab[this._saveAttribut] = false;
            allies2.datas = this.getListWithAttribValue(l, attributs.Allies, (int)allies.two);
            allies2.val = (int)allies.two;
            allies2.att = attributs.Allies;
            Node allies3 = new Node(curNode.attTab);
            allies3.attTab[this._saveAttribut] = false;
            allies3.datas = this.getListWithAttribValue(l, attributs.Allies, (int)allies.three);
            allies3.val = (int)allies.three;
            allies3.att = attributs.Allies;
            curNode.nodeTab.Add(allies0);
            curNode.nodeTab.Add(allies1);
            curNode.nodeTab.Add(allies2);
            curNode.nodeTab.Add(allies3);
            allies0.father = curNode;
            allies1.father = curNode;
            allies2.father = curNode;
            allies3.father = curNode;
            this.GenerateNodes(allies0.datas, allies0);
            this.GenerateNodes(allies1.datas, allies1);
            this.GenerateNodes(allies2.datas, allies2);
            this.GenerateNodes(allies3.datas, allies3);
        }

        private void diItForEnemyLevel(List<dataset> l, Node curNode)
        {
            Node low = new Node(curNode.attTab);
            low.attTab[this._saveAttribut] = false;
            low.datas = this.getListWithAttribValue(l, attributs.enemylevel, (int)enemylevel.low);
            low.val = (int)enemylevel.low;
            low.att = attributs.enemylevel;
            Node medium = new Node(curNode.attTab);
            medium.attTab[this._saveAttribut] = false;
            medium.datas = this.getListWithAttribValue(l, attributs.enemylevel, (int)enemylevel.medium);
            medium.val = (int)enemylevel.medium;
            medium.att = attributs.enemylevel;
            Node hard = new Node(curNode.attTab);
            hard.attTab[this._saveAttribut] = false;
            hard.datas = this.getListWithAttribValue(l, attributs.enemylevel, (int)enemylevel.high);
            hard.val = (int)enemylevel.high;
            hard.att = attributs.enemylevel;
            Node Vhard = new Node(curNode.attTab);
            Vhard.datas = this.getListWithAttribValue(l, attributs.enemylevel, (int)enemylevel.veryhigh);
            Vhard.attTab[this._saveAttribut] = false;
            Vhard.val = (int)enemylevel.veryhigh;
            Vhard.att = attributs.enemylevel;
            curNode.nodeTab.Add(low);
            curNode.nodeTab.Add(medium);
            curNode.nodeTab.Add(hard);
            curNode.nodeTab.Add(Vhard);
            low.father = curNode;
            medium.father = curNode;
            hard.father = curNode;
            Vhard.father = curNode;
            this.GenerateNodes(low.datas, low);
            this.GenerateNodes(medium.datas, medium);
            this.GenerateNodes(hard.datas, hard);
            this.GenerateNodes(Vhard.datas, Vhard);
        }

        private void doItForField(List<dataset> l, Node curNode)
        {
            Node NotFav = new Node(curNode.attTab);
            NotFav.attTab[this._saveAttribut] = false;
            NotFav.datas = this.getListWithAttribValue(l, attributs.field, (int)field.notfav);
            NotFav.val = (int)field.notfav;
            NotFav.att = attributs.field;
            Node Neutral = new Node(curNode.attTab);
            Neutral.attTab[this._saveAttribut] = false;
            Neutral.datas = this.getListWithAttribValue(l, attributs.field, (int)field.neutral);
            Neutral.val = (int)field.neutral;
            Neutral.att = attributs.field;
            Node Fav = new Node(curNode.attTab);
            Fav.attTab[this._saveAttribut] = false;
            Fav.datas = this.getListWithAttribValue(l, attributs.field, (int)field.fav);
            Fav.val = (int)field.fav;
            Fav.att = attributs.field;
            curNode.nodeTab.Add(NotFav);
            curNode.nodeTab.Add(Neutral);
            curNode.nodeTab.Add(Fav);
            NotFav.father = curNode;
            Neutral.father = curNode;
            Fav.father = curNode;
            this.GenerateNodes(NotFav.datas, NotFav);
            this.GenerateNodes(Neutral.datas, Neutral);
            this.GenerateNodes(Fav.datas, Fav);
        }

        private void doItForHunger(List<dataset> l, Node curNode)
        {
            Node low = new Node(curNode.attTab);
            low.datas = this.getListWithAttribValue(l, attributs.hunger, (int)hunger.low);
            low.attTab[this._saveAttribut] = false;
            low.val = (int)hunger.low;
            low.att = attributs.hunger;
            Node medium = new Node(curNode.attTab);
            medium.attTab[this._saveAttribut] = false;
            medium.datas = this.getListWithAttribValue(l, attributs.hunger, (int)hunger.medium);
            medium.val = (int)hunger.medium;
            medium.att = attributs.hunger;
            Node high = new Node(curNode.attTab);
            high.attTab[this._saveAttribut] = false;
            high.datas = this.getListWithAttribValue(l, attributs.hunger, (int)hunger.high);
            high.val = (int)hunger.high;
            high.att = attributs.hunger;
            curNode.nodeTab.Add(low);
            curNode.nodeTab.Add(medium);
            curNode.nodeTab.Add(high);
            low.father = curNode;
            medium.father = curNode;
            high.father = curNode;
            this.GenerateNodes(low.datas, low);
            this.GenerateNodes(medium.datas, medium);
            this.GenerateNodes(high.datas, high);
        }

        private void doItForLife(List<dataset> l, Node curNode)
        {
            Node low = new Node(curNode.attTab);
            low.attTab[this._saveAttribut] = false;
            low.datas = this.getListWithAttribValue(l, attributs.life, (int)life.low);
            low.val = (int)life.low;
            low.att = attributs.life;
            Node medium = new Node(curNode.attTab);
            medium.attTab[this._saveAttribut] = false;
            medium.datas = this.getListWithAttribValue(l, attributs.life, (int)life.medium);
            medium.val = (int)life.medium;
            medium.att = attributs.life;
            Node high = new Node(curNode.attTab);
            high.attTab[this._saveAttribut] = false;
            high.datas = this.getListWithAttribValue(l, attributs.life, (int)life.high);
            high.val = (int)life.high;
            high.att = attributs.life;
            curNode.nodeTab.Add(low);
            curNode.nodeTab.Add(medium);
            curNode.nodeTab.Add(high);
            low.father = curNode;
            medium.father = curNode;
            high.father = curNode;
            this.GenerateNodes(low.datas, low);
            this.GenerateNodes(medium.datas, medium);
            this.GenerateNodes(high.datas, high);
        }

        //Fin block de code degeuCrade

        public void GenerateNodes(List<dataset> l, Node curNode)
        {
            //Console.WriteLine("[NODE]OPEN");
            this.findBestGain(l, curNode);
            /*
            if (this._saveAttribut > -1)
                Console.WriteLine("save att : " + annexe.defineAttributs[this._saveAttribut]);
            else
                Console.WriteLine("No attrib save");
*/
            if (l.Count > 0)
            {
                double NbGood = 0;

                //Console.WriteLine((NbGood / l.Count).ToString() + "%");
                for (int i = 0; i < l.Count; ++i)
                    if (l[i].Result == result.good)
                        ++NbGood;
                //Console.WriteLine("les proba " + (NbGood / l.Count).ToString() + "%");
                curNode.prob = (NbGood / l.Count);
                if ((NbGood / l.Count) < 0.5)
                    curNode.Res = result.bad;
            }
            if (this._saveAttribut > -1)
            {
                if ((attributs)this._saveAttribut == attributs.Allies)
                {
                    //Console.WriteLine("Allies done");
                    this.doItForAllies(l, curNode);
                }
                else if ((attributs)this._saveAttribut == attributs.enemylevel)
                {
                    //Console.WriteLine("Enemy lv done");
                    this.diItForEnemyLevel(l, curNode);
                }
                else if ((attributs)this._saveAttribut == attributs.field)
                {
                    //Console.WriteLine("Field done");
                    this.doItForField(l, curNode);
                }
                else if ((attributs)this._saveAttribut == attributs.hunger)
                {
                    //Console.WriteLine("Hunger done");
                    this.doItForHunger(l, curNode);
                }
                else if ((attributs)this._saveAttribut == attributs.life)
                {
                    //Console.WriteLine("Life done");
                    this.doItForLife(l, curNode);
                }
            }

            //Console.WriteLine("[NODE]CLOSE");
        }
    }

    class Node
    {
        public attributs att;
        public int val;
        public List<bool> attTab = new List<bool>();
        public List<Node> nodeTab = new List<Node>();
        public List<dataset> datas;
        public result Res = result.good;
        public double prob = -1;
        public Node father = null;
        public Node()
        {
            this.attTab.Add(true);
            this.attTab.Add(true);
            this.attTab.Add(true);
            this.attTab.Add(true);
            this.attTab.Add(true);
        }
        public Node(List<bool> allready)
        {
            for (int i = 0; i < allready.Count; ++i)
                this.attTab.Add(allready[i]);
        }
    }
}
